<!DOCTYPE html> <html> <head> <meta charset='UTF-8'> <title>Document</title> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no" /> <style> </style> <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script> </head> <body> <div class="container"> <canvas id="myCanvas" width="100" height="100"></canvas> </div> <script> var canvas = document.getElementById("myCanvas"); var ctx = canvas.getContext('2d'); var cw = 100; var ch = 100; ctx.moveTo(50, 0); ctx.quadraticCurveTo(55 , 5 , 55 , 25); ctx.lineTo(55 , 40); ctx.arc(60 , 40 , 5 , Math.PI , Math.PI / 2 , true); ctx.lineTo(75 , 45); ctx.quadraticCurveTo( 95 , 45 , 100 , 50 ); ctx.lineTo(50 , 0); var gradient = ctx.createLinearGradient(50 , 50 , 75 , 75); gradient.addColorStop(0 , '#ccc'); gradient.addColorStop(0.7 , '#111'); gradient.addColorStop(1 , '#000'); ctx.fillStyle = gradient; ctx.fill(); ctx.beginPath(); ctx.moveTo(50,0); ctx.lineTo(100,50); ctx.lineTo(100,0); ctx.lineTo(50,0); ctx.closePath(); ctx.fillStyle = '#ff6600'; ctx.fill();
var deg = Math.PI / 180; ctx.globalCompositeOperation = 'source-atop'; ctx.beginPath(); ctx.font = '14px Arial'; ctx.textAlign = 'center'; ctx.translate(78 , 22); ctx.rotate(45 * deg); ctx.fillStyle = '#fff'; ctx.fillText('NEW' , 0 , 0); ctx.closePath();
ctx.globalCompositeOperation = 'source-atop'; </script> </body> </html>
|